function checkOldPwd() {
    var oldPwd = document.getElementById("oldPwd");
    if (oldPwd.value == "") {
        oldPwd.classList.add("wrong");
        alert("旧密码不能位空！");
        return false;
    } else {
        oldPwd.classList.remove("wrong");
        return true;
    }
}

function checkNewPwd() {
    var newPwd = document.getElementById("newPwd");
    if (newPwd.value.replace(/\s+/g, '') == "") {
        newPwd.classList.add("wrong");
        alert("密码不能位空！");
        return false;
    } else {
        var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/;
        if (regex.test(newPwd.value.replace(/\s+/g, ''))) {
            newPwd.classList.remove("wrong");
            return true;
        } else {
            newPwd.classList.add("wrong");
            alert("密码格式错误！");
            return false;
        }
    }
}

function checkReNewPwd() {
    var newPwd = document.getElementById("newPwd");
    var renewPwd = document.getElementById("renewPwd");
    if (checkNewPwd) {
        if (renewPwd.value.replace(/\s+/g, '') != newPwd.value.replace(/\s+/g, '')) {
            renewPwd.classList.add("wrong");
            alert("两次密码不一致！");
            return false;
        } else {
            renewPwd.classList.remove("wrong");
            return true;
        }
    }
}

function resetForm(){
    var oldPwd = document.getElementById("oldPwd");
    var newPwd = document.getElementById("newPwd");
    var renewPwd = document.getElementById("renewPwd");

    oldPwd.classList.remove("wrong");
    newPwd.classList.remove("wrong");
    renewPwd.classList.remove("wrong");
}

function checkForm() {
    if (checkOldPwd() && checkNewPwd() && checkReNewPwd()) {
        return true;
    } else {
        return false;
    }
}